<template>
  <config-provider :themes="themes" :i18n-render="i18nRender" :set-header="setHeader">
    <div :class="['layout-wrapper', $route.name]">
      <van-nav-bar
        v-if="showHeader"
        :title="header.title"
        :left-arrow="header.showBack"
        fixed
        z-index="99"
        safe-area-inset-top
        placeholder
        @click-left="onClickLeft"
        @click-right="onClickRight"
      >
        <template #right>
          <van-icon name="wap-home-o" size="18" />
        </template>
      </van-nav-bar>
      <Nuxt />
    </div>
  </config-provider>
</template>
<script>
import { ConfigProvider } from '@/components';
import LayoutMixin from '@/mixins/layout.mixin';

export default {
  name: 'LayoutDefault',
  components: {
    ConfigProvider,
  },
  mixins: [LayoutMixin],
  data() {
    return {
      title: '体检预约',
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      const path = this.header.rightPath;
      if (path.startsWith('http')) {
        window.location.href = path;
      } else {
        this.$router.push(path);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.layout-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
</style>
